package com.sghd.candy.module.fight.manager;

import com.sghd.candy.module.fight.FightConfig;
import com.sghd.common.ramcache.IEntity;
import com.sghd.common.ramcache.anno.*;
import com.sghd.common.ramcache.enhance.Enhance;
import com.sghd.pojo.candy.fight.enums.RoomStatus;

import javax.persistence.*;

/**
 * @author Allen
 * @date 2018/12/03
 */

@Entity
@Table(catalog = "bsdld")
@Cached(size = CachedSizes.DEFAULT, persister = @Persister(Persisters.PRE_HOUR))
@InitialConfig(type = InitialType.ALL)
public class ServerConfig implements IEntity<Integer> {
    @Id
    private Integer serverId;
    @Column(length = 20)
    private String serverIp;
    private Integer port;
    @Enumerated(EnumType.ORDINAL)
    private RoomStatus roomStatus;

    @Transient
    private Integer onLineCount = 0;
    @Transient
    private Integer maxLimit = FightConfig.ONLINE_MAXLIMIT;

    public Integer getServerId() {
        return serverId;
    }

    void setServerId(Integer serverId) {
        this.serverId = serverId;
    }

    public String getServerIp() {
        return serverIp;
    }

    void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }

    public Integer getPort() {
        return port;
    }

    void setPort(Integer port) {
        this.port = port;
    }

    public RoomStatus getRoomStatus() {
        return roomStatus;
    }

    void setRoomStatus(RoomStatus roomStatus) {
        this.roomStatus = roomStatus;
    }

    public Integer getOnLineCount() {
        return onLineCount;
    }

    void setOnLineCount(Integer onLineCount) {
        this.onLineCount = onLineCount;
    }

    public Integer getMaxLimit() {
        return maxLimit;
    }

    void setMaxLimit(Integer maxLimit) {
        this.maxLimit = maxLimit;
    }

    @Enhance
    void changeRoomStatus(RoomStatus roomStatus) {
        this.roomStatus = roomStatus;
    }

    @Override
    public Integer getId() {
        return this.serverId;
    }
}
